package com.sapitest.script.goodslisttest.paracheck;

import com.sapitest.imp.TestCases;
import com.sapitest.imp.TestData;
import com.sapitest.keywords.asserts.BaseAssert;
import com.sapitest.keywords.asserts.JSONAssert;
import com.sapitest.utils.ConfigFile;
import com.sapitest.utils.bean.Response;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

/**
 * 接口/v1/goodslist参数lang校验
 */
public class LangTest {
    @BeforeClass
    public void beforeClass() {
    }

    @Test(description= "lang为null")
    public void testcase001(){
        String exp = TestData.getExpResponseData(ConfigFile.getTestParameter("MY_SHOPPING_TROLLEY_TABLE"),25);
        Response response = TestCases.testMyShoppingTrolley(25);
        BaseAssert.numEquals(response.getResponseCode(), 200);
        JSONAssert.jsonObjectEquals(response.getResponseBody(), exp);
    }

    @Test(description= "lang为空")
    public void testcase002(){
        String exp = TestData.getExpResponseData(ConfigFile.getTestParameter("MY_SHOPPING_TROLLEY_TABLE"),26);
        Response response = TestCases.testMyShoppingTrolley(26);
        BaseAssert.numEquals(response.getResponseCode(), 200);
        JSONAssert.jsonObjectEquals(response.getResponseBody(), exp);
    }

    @Test(description= "lang长度超过10")
    public void testcase003(){
        String exp = TestData.getExpResponseData(ConfigFile.getTestParameter("MY_SHOPPING_TROLLEY_TABLE"),27);
        Response response = TestCases.testMyShoppingTrolley(27);
        BaseAssert.numEquals(response.getResponseCode(), 200);
        JSONAssert.jsonObjectEquals(response.getResponseBody(), exp);
    }

    @Test(description= "lang长度等于10")
    public void testcase004(){
        String exp = TestData.getExpResponseData(ConfigFile.getTestParameter("MY_SHOPPING_TROLLEY_TABLE"),28);
        Response response = TestCases.testMyShoppingTrolley(28);
        BaseAssert.numEquals(response.getResponseCode(), 200);
        JSONAssert.jsonObjectEquals(response.getResponseBody(), exp);
    }

    @Test(description= "lang长度等于1")
    public void testcase005(){
        String exp = TestData.getExpResponseData(ConfigFile.getTestParameter("MY_SHOPPING_TROLLEY_TABLE"),29);
        Response response = TestCases.testMyShoppingTrolley(29);
        BaseAssert.numEquals(response.getResponseCode(), 200);
        JSONAssert.jsonObjectEquals(response.getResponseBody(), exp);
    }

    @Test(description= "lang传入int类型")
    public void testcase006(){
        String exp = TestData.getExpResponseData(ConfigFile.getTestParameter("MY_SHOPPING_TROLLEY_TABLE"),30);
        Response response = TestCases.testMyShoppingTrolleyReplaceValue(30, "lang", 1);
        BaseAssert.numEquals(response.getResponseCode(), 200);
        JSONAssert.jsonObjectEquals(response.getResponseBody(), exp);
    }

    @Test(description= "lang不传")
    public void testcase007(){
        String exp = TestData.getExpResponseData(ConfigFile.getTestParameter("MY_SHOPPING_TROLLEY_TABLE"),31);
        Response response = TestCases.testMyShoppingTrolleyWithoutPara(31, "lang");
        BaseAssert.numEquals(response.getResponseCode(), 200);
        JSONAssert.jsonObjectEquals(response.getResponseBody(), exp);
    }

    @AfterClass
    public void afterClass() {
    }
}
